function focusTag(obj)
{
    if (obj.value == 'Tag current config...')
    {
        obj.value = '';
        obj.style.color = '#000000';
        _gel("tagadd").style.color = "";
    }
}

function blurTag(obj)
{
    if (obj.value == '')
    {
        obj.value = 'Tag current config...';
        obj.style.color = '#cccccc';
        _gel("tagadd").style.color = "#cccccc";
    }
}


function addTag(tagName, deleteTag)
{
    var url = "";

    if ((tagName == "") || (tagName == 'Tag current config...'))
    {
        return;    
    }

    if (!deleteTag)
    {
        url = "localdeveloper.php?tagName=" + encodeURI(tagName) + "&settingsUrl=" + encodeURI(window.location);
    }
    else
    {
         url = "localdeveloper.php?deleteTag=1&tagName=" + encodeURI(tagName);
    }



    var httpRequest;

    if (window.XMLHttpRequest)
    { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    { // IE
        try
        {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
            }
        }
    }

    if (!httpRequest)
    {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = function()
    {
        onGotResponse(httpRequest, tagName, deleteTag);
    };
    httpRequest.open('GET', url, true);
    httpRequest.send('');
}

function onGotResponse(httpRequest, tagName, deleteTag)
{

    if (httpRequest.readyState == 4)
    {
        if ((httpRequest.status == 200) && (httpRequest.responseText == "OK"))
        {
            if (!deleteTag)
            {
                //add row to table
                var row = _gel("recentSettingsTable").insertRow(0);
                var td1 = row.insertCell(0);
                var td2 = row.insertCell(1);
                td2.style.textAlign = "right";
                var here = window.location;
                var now = new Date();
                td1.innerHTML = "&nbsp;&nbsp;<a href='" + here + "'>" + tagName + "</>";
                td2.innerHTML = "<a href='javascript:void(0)' onclick='addTag(\"" + tagName + "\", this);'>delete this tag</a>";
            }
        else
        {
            //delete row from table
            var t = _gel("recentSettingsTable");
            t.deleteRow(deleteTag.parentNode.parentNode.rowIndex)
        }

        }
        else
        {
            alert('There was a problem with the request. HTTP status: ' + httpRequest.status + " response: " + httpRequest.responseText);
        }

        _gel("configTag").value = "Tag current config...";
        _gel("tagadd").style.color = "#cccccc";
        _gel("configTag").style.color = "#cccccc";
    }

}